<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : feed-user-toHtml.xsl
    Created on : June 10, 2013, 3:32 PM
    Author     : Hoang
    Description:
        Purpose of transformation follows.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:f-u="http://xml.netbeans.org/schema/feedback-user" exclude-result-prefixes="f-u">
    <xsl:output method="html" indent="yes" encoding="UTF-8"/>
    <xsl:param name="sort">sendDate</xsl:param>
    <xsl:param name="order">descending</xsl:param>
    <xsl:template match="/">
        <ol id="ord-list" >
            <xsl:for-each select="//f-u:feedback">
                <xsl:sort select="*[local-name()=$sort]" order="{$order}"/>
                <li class="item">
                    <form method="post" action="deleteFeedback.action">
                        <input type="hidden" name="feedbackID">
                            <xsl:attribute name="value">
                                <xsl:value-of select="f-u:feedbackID"/>
                            </xsl:attribute>
                        </input>
                        <div class="actions">
                            <button class="del" onClick="return confirmDelete(this.form);">
                                <span>Xóa</span>
                            </button>
                        </div>
                    
                        <table >
                            <tr>
                                <th>Chủ đề</th>
                                <td>
                                    <div class="show">
                                        <h3 class="h3">
                                            <xsl:value-of select="f-u:title"/>
                                        </h3>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <th>Người gửi</th>
                                <td>
                                    <div class="show">
                                        <p>
                                            <xsl:value-of select="f-u:username"/>
                                        </p>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <th>Nội dung</th>
                                <td>
                                    <p>
                                        <xsl:value-of select="f-u:feedbackContent"/>
                                    </p>
                                </td>
                            </tr>
                            <tr>
                                <th>Ngày gửi</th>
                                <td>
                                    <div class="show">
                                        <xsl:call-template name="formatDate">
                                            <xsl:with-param name="dateIn">
                                                <xsl:value-of select='f-u:sendDate'/>
                                            </xsl:with-param>
                                        </xsl:call-template>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </form>
                </li>
            </xsl:for-each>
        </ol>
    </xsl:template>

<!-- Dung de format ngay thang -->
    <xsl:template name="formatDate">

        <xsl:param name="dateIn" />
        <xsl:variable name="year" select="substring($dateIn, 1, 4)" />
        <xsl:variable name="month" select="substring($dateIn, 6, 2)" />
        <xsl:variable name="date" select="substring($dateIn, 9, 2)" />
        <xsl:variable name="time" select="substring($dateIn, 12, 8)" />
        <xsl:value-of select="concat('Ngày ',$date, '/', $month, '/', $year,' lúc ',$time)" />

    </xsl:template>

</xsl:stylesheet>
